package cn.usian.jyzx.product.controller;

import cn.usian.jyzx.model.entity.product.Category;
import cn.usian.jyzx.model.vo.common.Result;
import cn.usian.jyzx.model.vo.common.ResultCodeEnum;
import cn.usian.jyzx.product.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2024 06 14 11 03
 **/
@Tag(name = "分类接口管理")
@RestController
@RequestMapping(value="/api/product/category")
@CrossOrigin
public class CategoryController {

  @Autowired
  CategoryService categoryService;

  @Operation(summary = "获取分类树形数据")
  @GetMapping("findCategoryTree")
  public Result<List<Category>> findCategoryTree(){
    List<Category> categoryTree = categoryService.findCategoryTree();
    return Result.build(categoryTree, ResultCodeEnum.SUCCESS);
  }


}
